﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Visifire.Charts;



namespace PruebaGraficas
{
    /// <summary>
    /// Lógica de interacción para vGraficas.xaml
    /// </summary>
    public partial class vGraficas : Window
    {
        public vGraficas()
        {
            InitializeComponent();
        }



        private void DibujarGraficoBarras(List<ClassLista> leyenda)
        {
            Chart chart = new Chart();
            DataSeries dataSeries = new DataSeries();
            Title title = new Visifire.Charts.Title();
                       
            title.Text = "Unidades Vendidas por Categoría";

            chart.Titles.Add(title);
            chart.Width = 500;
            chart.Height = 300;
            SolidColorBrush pincelFondoGrafico = new SolidColorBrush(Colors.Black);
            chart.Background = pincelFondoGrafico;
            chart.AnimationEnabled = true;
            chart.Theme = "Theme1"; // Colores de las barritas
            chart.ShadowEnabled = true;
            chart.LightingEnabled = true;
            chart.View3D = true;

            //chart.AnimationType = "Type3";
            //chart.UniqueColors = true;
                        
            foreach (ClassLista v in leyenda)
            {
                DataPoint dataPoint = new DataPoint();
                dataPoint.YValue = v.Cant;
                dataPoint.AxisXLabel = v.NombreCat;
                dataSeries.DataPoints.Add(dataPoint);
            }

            dataSeries.RenderAs = RenderAs.Column;

            chart.Series.Add(dataSeries);
            contenedor.Children.Add(chart);
                        
        }


        private void DibujarGraficoDonuts(List<ClassLista> leyenda)
        {
            Chart chart = new Chart();
            DataSeries dataSeries = new DataSeries();
            Title title = new Visifire.Charts.Title();

            title.Text = "Unidades Vendidas por Categoría";

            chart.Titles.Add(title);
            chart.Width = 500;
            chart.Height = 300;
            SolidColorBrush pincelFondoGrafico = new SolidColorBrush(Colors.Black);
            chart.Background = pincelFondoGrafico;
            chart.AnimationEnabled = true;
            chart.Theme = "Theme1"; // Colores de las barritas
            chart.ShadowEnabled = true;
            chart.LightingEnabled = true;
            chart.View3D = true;

            //chart.AnimationType = "Type3";
            //chart.UniqueColors = true;

            foreach (ClassLista v in leyenda)
            {
                DataPoint dataPoint = new DataPoint();
                dataPoint.YValue = v.Cant;
                dataPoint.AxisXLabel = v.NombreCat;
                dataSeries.DataPoints.Add(dataPoint);
            }

            dataSeries.RenderAs = RenderAs.Doughnut;

            chart.Series.Add(dataSeries);
            contenedor.Children.Add(chart);



        }


        private void radioButton1_Checked(object sender, RoutedEventArgs e)
        {


            List<ClassLista> leyenda = Window1.lista;
            
            DibujarGraficoBarras(leyenda);
        }

        private void radioButton2_Checked(object sender, RoutedEventArgs e)
        {
            List<ClassLista> leyenda = Window1.lista;

            DibujarGraficoDonuts(leyenda);
        }
    }
}
